package org.fh.controller;

import org.fh.controller.api.DataControllerApi;
import org.fh.domain.LampControl;
import org.fh.domain.LampStatus;
import org.fh.domain.ModeSwitch;
import org.fh.inductionLamp.impl.response.GetConfigResponse;
import org.fh.inductionLamp.impl.response.LampControlResponse;
import org.fh.inductionLamp.impl.response.ModeSwitchResponse;
import org.fh.servcie.DataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: wwy
 * @Date: 2020/10/22 14:24
 */
@RestController
@RequestMapping("/data")
public class DataController implements DataControllerApi {
    @Autowired
    private DataService dataService;

    /**
     * 获取配置
     * @return
     */
    @GetMapping("/getConfig/{srcId}/{destId}")
    public GetConfigResponse getConfig(@PathVariable("srcId") int srcId,@PathVariable("destId") int destId){
        return dataService.getConfig(srcId,destId);
    }

    /**
     * 更改模式
     * @param modeSwitch
     * @return
     */
    @PostMapping("/modeSwitch")
    public ModeSwitchResponse modeSwitch(@RequestBody ModeSwitch modeSwitch){
        return dataService.modeSwitch(modeSwitch);
    }

    /**
     * 灯光控制
     * @param lampControl
     * @return
     */
    @PostMapping("/lampController")
    @Override
    public LampControlResponse lampController(@RequestBody LampControl lampControl) {
        return dataService.lampController(lampControl);
    }

    /**
     * 获取设备配置信息
     * @return
     */
    @GetMapping("/getLampStatus")
    @Override
    public LampStatus getLampStatus() {
        return dataService.getLampStatus();
    }

    /**
     * 获取全部配置
     * @param srcId
     * @return
     */
    @GetMapping("/getConfigAll/{srcId}")
    @Override
    public List<GetConfigResponse> getConfigAll(@PathVariable("srcId") int srcId) {
        return dataService.getConfigAll(srcId);
    }
}
